<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>商家列表</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <!-- <link rel="stylesheet" type="text/css" href="../css/aui-indexed-list.css"/> -->
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <style>
        .aui-img-object{
            width: 45px !important;
            height: 45px !important;
        }
        .aui-img-body{
            color:#333;
            line-height: 45px;
            padding-left: 12px;
        }
/*        body {
            background-color: #f3f3f3;
            font-size: 13px;
        }

        .aui-indexed-list-bar {
            top: 65px;
        }

        .w20 {
            width: 20%;
        }

        .zfTitle {
            padding: 8px 10px;
        }

        .shili .aui-list-view.aui-grid-view .aui-list-view-cell .aui-img-body {
            padding: 18px 0;
        }

        .shili .aui-list-view.aui-grid-view {
            padding-bottom: 5px;
        }

        .shili .aui-list-view-cell {
            float: left;
            width: 100%;
        }

        .aui-indexed-list-view li.aui-list-view-cell img {
            width: 40px;
            height: 40px;
            line-height: 40px;
            margin-right: 8px;
            vertical-align: middle;
        }

        .aui-list-view-cell {
            padding: 6px 15px;
        }
        .aui-indexed-list{
            top: 0;
            width: 100%;
        }*/
    </style>
</head>
<body>
<div class="aui-indexed-list">
    <div class="shili bgWhite">
        <div class="kongshuju">
            <p>暂无数据</p>
        </div>
        <ul id="seller-content">

        </ul>
    </div>
</div>
<script id="seller-template" type="text/x-dot-template">
<!--     {{ for(var i in it){ }}
    <li class="aui-list-view-cell" tapmode onclick="go2Shop('{{=it[i].userid}}')">
        <img class="aui-img-object" src="{{=it[i].bgurl}}">{{=it[i].company}}
    </li>
    {{ } }} -->
    {{for (var i in it) { }}
    <li class="aui-list-view-cell aui-img" onclick="go2Shop({{=it[i].userid}})" style="background: #fff;">
        <img class="aui-img-object aui-pull-left" src="{{=it[i].bgurl}}">
        <div class="aui-img-body aui-ellipsis-1">
            {{=it[i].company}}
        </div>
    </li>
    {{ } }}
</script>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript">
    var isLock = false,page=1;
    apiready = function () {
        api.parseTapmode();
        searchValue=api.pageParam.searchValue;

        api.setRefreshHeaderInfo({
            visible : true,
            loadingImg : 'widget://image/ptr_pull.png',
            bgColor : '#efeff4',
            textColor : '#959595',
            textDown : '下拉刷新',
            textUp : '松开刷新',
            showTime : true
        }, function(ret, err) {
            isLock=false;
            page = 1;
            getData(page);
        });
        //重新登录监听
        api.addEventListener({
            name : 'reGetMyInfo'
        }, function(ret) {
            if (ret && ret.value) {
                page = 1;
                isLock=false;
                api.refreshHeaderLoading();
            }
        });
        api.refreshHeaderLoading();

        //监听是否达到底部上拉加载7
        api.addEventListener({
            name: 'scrolltobottom'
        }, function (ret, err) {
            page++;
            if (isLock == false) {
                getData();
            }
        })
    }

    function getData(toPage) {
        if(isLock)return;
        toPage=toPage?toPage:page;
        if(toPage==1)api.refreshHeaderLoading();
        
        var data = {};
        data['page'] = toPage;
        data['keyWord'] = searchValue;
        data['searchType'] = 2;
        data['goodsType'] = 1;
        var url="Search/search";
        ajaxRequest(url, 'post', data, function (ret, err) {
            api.refreshHeaderLoadDone();
            isLock = false;
            if (ret.status == 1) {
                var tpl = $api.byId('seller-template').text;
                var content = $api.byId("seller-content");
                var tempFn = doT.template(tpl);
                if (page > 1) {
                    if(!$.trim(ret.msg)){
                        isLock=true;
                        return;
                    }
                    $api.append(content, tempFn(ret.msg));
                } else {
                    $api.html(content, tempFn(ret.msg));
                }
            } else {
                isLock = true;
                api.toast({
                    msg: ret.msg,
                    duration: 2000,
                    location: 'bottom'
                });
            }
        });
    }
</script>
</html>